modifier_item_suit_hanyue = class({})

local public = modifier_item_suit_hanyue

--------------------------------------------------------------------------------

function public:IsDebuff()
	return false
end

--------------------------------------------------------------------------------

function public:IsHidden()
	return false
end

--------------------------------------------------------------------------------

function public:IsPurgable()
	return false
end

--------------------------------------------------------------------------------

function public:GetTexture()
	return 'item_0617'
end

--------------------------------------------------------------------------------

function public:DeclareFunctions()
	local funcs = {
		MODIFIER_EVENT_ON_ATTACKED,
	}
	return funcs
end

--------------------------------------------------------------------------------

function public:OnAttacked(keys)
	if IsServer() then
		local target = keys.target
		local attacker = keys.attacker
		local caster = self:GetCaster()

		-- 受到攻击
		if target == caster and attacker ~= caster then
			target:Heal(10000, nil)
			return
		end

		-- 攻击
		if RollPercentage(10) then
			if target:IsAlive() and target ~= caster and attacker == caster then
				target:AddNewModifier(target, nil, "modifier_item_suit_liudao_effect", {duration=1})
				ApplyDamage({
					attacker = attacker,
					victim = target,
					damage = keys.damage*4,
					damage_type = DAMAGE_TYPE_PHYSICAL,
				})
			end
		end
	end
end

--------------------------------------------------------------------------------